package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.HolyType;
import com.isunland.managesystem.utils.LogUtil;
import java.util.ArrayList;

public class HolyTypeDialogFragment extends BaseNetworkDialogFragment {

  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> customerDialogs = new ArrayList<>();
    try {
      HolyType[] holyTypes = new Gson().fromJson(arg0, HolyType[].class);
      if (holyTypes == null || holyTypes.length <= 0) {

        return null;
      }

      for (int i = 0; i < holyTypes.length; i++) {
        customerDialogs.add(new CustomerDialog(holyTypes[i].getTEXT(), holyTypes[i].getID()));
      }
    } catch (Exception e) {
      LogUtil.e(TAG, "Exception", e);
    }

    return customerDialogs;
  }

  @Override public String getUrl() {
    return ApiConst.URL_NEW_HOLY_TYPE;
  }
}
